package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetMealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    @AutoFill(OperationType.INSERT)
    @Insert("insert into setmeal (category_id, name, price, status, description, image, create_time, update_time," +
            " create_user, update_user) values (#{categoryId},#{name},#{price},#{status},#{description},#{image}," +
            "#{createTime},#{updateTime},#{createUser},#{updateUser})")

    void insert(Setmeal setMeal);

    List<SetMealVO> pageQuery(SetmealPageQueryDTO setMealPageQueryDTO);

    @Select("select * from setmeal where id = #{id}")
    SetmealDTO getById(Long id);

    @AutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);

    void delete(List<Long> ids);

    @Select("select count(*) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);
}
